﻿//初始化地址
//var A_Url = '220.169.146.17:8083';
//var B_Url = '220.169.146.17:8080';
var A_Url = '10.10.10.100:54954';//window.location.host;'127.0.0.1:54954';//
var B_Url = '10.10.10.100:54954';
//var A_Url = '220.169.146.17:8083';//8083顾客用
//var B_Url = '220.169.146.17:8083';
//var A_Url = '220.169.146.17:8080';//8080药店用
//var B_Url = '220.169.146.17:8080';

var Xian_ID = "8"; //龙山县

//设置cookie
function setCookie(key, value) {
    var expiredays = 356 * 24 * 60 * 60 * 1000;
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = key + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

//取回cookie
function getCookie(key) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(key + "=");
        if (c_start != -1) {
            c_start = c_start + key.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) {
                c_end = document.cookie.length;
            }
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

//获取get
function getQuery(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) { return pair[1]; }
    }
    return '';
}

//校验身份证
function checkIdCard(idcard) {
    const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (!regIdCard.test(idcard)) {
        errorMsg = '身份证号填写有误';
        return false;
    } else {
        return true;
    }
}

//校验手机号码
function checkPhone(phone) {
    if (!(/^1[3456789]\d{9}$/.test(phone))) {
        return false;
    }
    return true;
}

//获取时间树
function getDateNumber(datetime) {
    var now = new Date(datetime);
    var year = now.getFullYear(); //得到年份
    var month = now.getMonth();//得到月份
    var date = now.getDate();//得到日期
    var day = now.getDay();//得到周几
    var hour = now.getHours();//得到小时
    var minu = now.getMinutes();//得到分钟
    var sec = now.getSeconds();//得到秒
    month = month + 1;
    if (month < 10) month = "0" + month;
    if (date < 10) date = "0" + date;
    if (hour < 10) hour = "0" + hour;
    if (minu < 10) minu = "0" + minu;
    if (sec < 10) sec = "0" + sec;
    var time = "";
    time = year + month + date;
    return time;
}

function formartDateInt(str) {
    str = str + '';
    var newstr = str.slice(0, 4) + '-' + str.slice(4, 6) + '-' + str.slice(6, 8);
    return newstr;
}